﻿#region << 文件说明 >>
/*----------------------------------------------------------------
 * 命名空间：Vampirewal.ToolCenter.ViewModel
 * 唯一标识：09186ec6-f1ed-4fb9-8a95-4e688c995a33
 * 文件名：BootStartup
 * 
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2023/12/26 12:39:39
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/
#endregion << 文件说明 >>

global using Microsoft.Extensions.DependencyInjection;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using Vampirewal.Core.Components;
global using Vampirewal.Core.ConfigOptions;
global using Vampirewal.Core.Extensions;
global using SqlSugar;
using Vampirewal.ToolCenter.ViewModel.Services;

namespace Vampirewal.ToolCenter.ViewModel;

/// <summary>
/// 
/// </summary>
public partial class BootStartup:VampirewalBootStartUp
{
    public BootStartup():base()
    {
        loadPluginService = new LoadPluginService();
    }

    private LoadPluginService loadPluginService { get; set; }

    private Action<bool> AppRun { get; set; }

    protected override string FirstViewKey => "Vampirewal.ToolCenter.MainView";

    public override void OnAppExit(bool IsRun)
    {

    }

    public override void OnAppRun(bool IsRun)
    {
        AppRun?.Invoke(IsRun);
    }

    protected override void RegisterService(IServiceCollection services)
    {
        loadPluginService.Services = services;

        services.AddVampirewalCoreConfig($"{AppDomain.CurrentDomain.BaseDirectory}AppConfig.json", options =>
        {
            loadPluginService.Options = options;
            loadPluginService.Load();
            AppRun = loadPluginService.OnAppRun;
            //options.RegisterOptions<DbBaseOptions>();
        });
        
        services.AddSingleton<ILoadPluginService>(loadPluginService);

        services.UseVampirewalCoreSqlSugar<ToolDataContext>();
        services.AddTransient(typeof(SqlSugarRepository<>));
        services.AddVampirewalCoreDialogMessage();
    }


}